﻿using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ImageTaskModule
{
    public partial class FormTaskItemSetting : DevExpress.XtraEditors.XtraForm
    {
        public FormTaskItemSetting()
        {
            InitializeComponent();
        }

        private void FormTaskItemSetting_Load(object sender, EventArgs e)
        {
            gridControl全局视觉任务.DataSource = ImageTaskManager.taskCenterGlobal.listTasks;
            gridControl项目视觉任务.DataSource = ImageTaskManager.taskCenter.listTasks;
        }

        private void gridControl项目视觉任务_DoubleClick(object sender, EventArgs e)
        {
            GridView gridView = gridControl项目视觉任务.MainView as GridView;
            int iIndex = gridView.GetFocusedDataSourceRowIndex();
            if (iIndex > -1)
            {
                FormImageTaskItem formImageTaskItem = new FormImageTaskItem(ImageTaskManager.taskCenter.listTasks[iIndex]);
                formImageTaskItem.TopLevel = false;
                formImageTaskItem.Size = this.Size;
                this.Controls.Add(formImageTaskItem);
                formImageTaskItem.Show();
                formImageTaskItem.BringToFront();
            }
        }

        private void gridControl全局视觉任务_DoubleClick(object sender, EventArgs e)
        {
            GridView gridView = gridControl全局视觉任务.MainView as GridView;
            int iIndex = gridView.GetFocusedDataSourceRowIndex();
            if (iIndex > -1)
            {
                FormImageTaskItem formImageTaskItem = new FormImageTaskItem(ImageTaskManager.taskCenterGlobal.listTasks[iIndex]);
                formImageTaskItem.TopLevel = false;
                formImageTaskItem.Size = this.Size;
                this.Controls.Add(formImageTaskItem);
                formImageTaskItem.Show();
                formImageTaskItem.BringToFront();
            }
        }
    }
}